﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Ex03.VehicalsObjectModel
{
    public abstract class VehicalEnergySystem
    {
        // Members
        protected float m_CurrentAmount;
        protected float m_MaxAmount;

        /// <summary>
        /// Initializes the base energy system
        /// </summary>
        /// <param name="i_MaxAmount">The maximum amount of abstract energy</param>
        /// <exception cref="ArgumentException">On negtaive amount</exception>
        public VehicalEnergySystem(float i_MaxAmount)
        {
            // Check the fule amount
            if (i_MaxAmount < 0)
            {
                throw new ArgumentException("Negtaive fule amount not allowed");
            }
            else
            {
                m_MaxAmount = i_MaxAmount;
                m_CurrentAmount = 0;
            }
        }

        /// <summary>
        /// Gets the percentage of currently available energy
        /// </summary>
        public int CurrentEnergyPercent
        {
            get
            {
                return (int)(100 * (m_CurrentAmount / m_MaxAmount));
            }
        }

        public eFuleType eFuleType
        {
            get
            {
                throw new System.NotImplementedException();
            }
            set
            {
            }
        }

        /// <summary>
        /// Adds a given amount to the total amount of energy
        /// </summary>
        /// <param name="i_AddedAmount">The amount of energy to add</param>
        /// <exception cref="ValueOutOfRangeException">When the amount is negative or exceeds the capacity of the system</exception>
        protected void AddEnergy(float i_AddedAmount)
        {
            if (i_AddedAmount < 0 || i_AddedAmount + m_CurrentAmount > m_MaxAmount)
            {
                throw new ValueOutOfRangeException(0, m_MaxAmount - m_CurrentAmount);
            }
            else
            {
                // Add the fule to the system
                m_CurrentAmount += i_AddedAmount;
            }
        }
    }
}
